package com.itheima.pool;

import java.util.concurrent.Executors;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/*
自己创建线程池
 */
public class Demo03 {


    public static void main(String[] args) {
        /*
        核心线程数 ,最大线程数,空闲时间数,空闲时间单位
        阻塞队列,线程工厂,拒绝策略
         */
        ThreadPoolExecutor pool = new ThreadPoolExecutor(
             5,
             5,
             60,
             TimeUnit.SECONDS,
             new LinkedBlockingQueue<>(),
                Executors.defaultThreadFactory(),
                new ThreadPoolExecutor.AbortPolicy());
        for (int i = 0; i < 10; i++) {
            pool.submit(()->{
                System.out.println(Thread.currentThread().getName()+"执行了");
            });
        }
    }
}
